package config

import "hyper/supports/configs"

func init() {

	configs.Add("database", func() map[string]interface{} {
		return map[string]interface{}{

			// 默认数据库
			"connection": configs.Env("DB_CONNECTION", "mysql"),

			"mysql": map[string]interface{}{

				// 数据库链接信息
				"host":     configs.Env("DB_HOST", "127.0.0.1"),  // 主机信息
				"port":     configs.Env("DB_PORT", "3306"),       // 端口
				"username": configs.Env("DB_USERNAME", "root"),   // 用户名
				"password": configs.Env("DB_PASSWORD", ""),       // 密码
				"database": configs.Env("DB_DATABASE", ""),       // 数据库名
				"charset":  configs.Env("DB_CHARSET", "utf8mb4"), // 数据库编码
				"prefix":   configs.Env("DB_PREFIX", ""),         // 表前缀

				// 连接池配置
				"max_idle_connections": configs.Env("DB_MAX_IDLE_CONNECTIONS", 100),
				"max_open_connections": configs.Env("DB_MAX_OPEN_CONNECTIONS", 25),
				"max_life_seconds":     configs.Env("DB_MAX_LIFE_SECONDS", 5*60),
			},

			// sqlite 数据库
			"sqlite": map[string]interface{}{
				"database": configs.Env("DB_SQL_FILE", "database/database.db"),
			},

			// postgres 数据库
			"postgres": map[string]interface{}{
				"host":     configs.Env("DB_HOST", "127.0.0.1"),
				"port":     configs.Env("DB_PORT", "5432"),
				"username": configs.Env("DB_USERNAME", "postgres"),
				"password": configs.Env("DB_PASSWORD", ""),
				"database": configs.Env("DB_DATABASE", ""),
				"charset":  configs.Env("DB_CHARSET", "utf8mb4"),
				"prefix":   configs.Env("DB_PREFIX", ""),
			},

			//  clickHouse 数据库
			"clickHouse": map[string]interface{}{
				"host":     configs.Env("DB_HOST", "127.0.0.1"),
				"username": configs.Env("DB_USERNAME", "postgres"),
				"password": configs.Env("DB_PASSWORD", ""),
				"database": configs.Env("DB_DATABASE", ""),
				"charset":  configs.Env("DB_CHARSET", "utf8mb4"),
				"prefix":   configs.Env("DB_PREFIX", ""),
			},
		}
	})

}
